<?php

namespace api\modules\v1\controllers\marketing;

use Yii;
use api\controllers\OnAuthController;
use common\models\marketing\CallbackStatus;
use common\helpers\CommonHelper;

/**
 * Class CallbackStatusController
 * @package api\modules\v1\controllers\marketing
 */
class CallbackStatusController extends OnAuthController
{
    /**
     * @var CallbackStatus
     */
    public $modelClass = CallbackStatus::class;

    /**
     * @api {get} /v1/marketing/callback-status/index 回访状态列表
     * @apiName index
     * @apiGroup CallbackStatus
     */
    public function actionIndexCallbackStatus()
    {
        $projectId = $this->projectId;

        // 查询结果
        $data = Yii::$app->services->marketingCallbackStatus->getList($projectId);

        return $data;
    }

    /**
     * @api {post} /v1/marketing/callback-status/create 新增回访状态
     * @apiName create
     * @apiGroup CallbackStatus
     *
     * @apiParam {String} name              回访状态名称
     * @apiParam {Number} status            【1启用、0停用】
     */
    public function actionCreateCallbackStatus()
    {
        $params = Yii::$app->request->post();
        $params['member_id'] = Yii::$app->user->identity->member_id;
        $params['project_id'] = $this->projectId;

        return Yii::$app->services->marketingCallbackStatus->create($params);
    }

    /**
     * @api {post} /v1/marketing/callback-status/update 编辑回访状态
     * @apiName update
     * @apiGroup CallbackStatus
     *
     * @apiParam {Number} id                回访状态ID
     * @apiParam {Number} status            状态【0停用 1启用】
     */
    public function actionUpdateCallbackStatus()
    {
        $params = Yii::$app->request->post();
        $params['member_id'] = Yii::$app->user->identity->member_id;
        $params['project_id'] = $this->projectId;
        return Yii::$app->services->marketingCallbackStatus->update($params);
    }


    /**
     * @api {post} /v1/marketing/callback-status/update-status 编辑回访状态的状态
     * @apiName update-status
     * @apiGroup CallbackStatus
     *
     * @apiParam {Number} id                回访状态ID
     * @apiParam {Number} status            状态【0停用 1启用】
     */
    public function actionUpdateCallbackStatusAboutStatus()
    {
        $id = Yii::$app->request->post('id');
        $status = Yii::$app->request->post('status');

        return Yii::$app->services->marketingCallbackStatus->updateStatus($id, $status);
    }

    /**
     * @api {post} /v1/marketing/callback-status/delete 删除回访状态
     * @apiName delete
     * @apiGroup CallbackStatus
     *
     * @apiParam {Number} id                回访状态ID
     */
    public function actionDeleteCallbackStatus()
    {
        $id = Yii::$app->request->post('id');

        return Yii::$app->services->marketingCallbackStatus->delete($id);
    }

}